package com.jml.生命周期003.processor;


import com.jml.生命周期003.processor.entity.MemberEntity生命周期基于接口;
import com.jml.生命周期003.processor.entity001.PayEntity;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author:jml
 * @date: 2019/9/24 10:44
 * @description：
 */
@Component
public class MyApplicationContext001 implements ApplicationContextAware {

	//封装作为全局的
	private static ApplicationContext applicationContext;

	public MyApplicationContext001() {
		System.out.println("init applicationContextAware");
	}

	//这个方法在这个类初始化后的时候就执行了
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		MyApplicationContext001.applicationContext = applicationContext;
		PayEntity payEntity = applicationContext.getBean("payEntity", PayEntity.class);
		System.out.println("ApplicationContextAware==========="+payEntity);
	}
}
